package com.google.code.fluentjoiner;

import com.google.common.base.Function;
import com.google.common.collect.ImmutableMap;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

public class Person
{
    public static final Function<ImmutableMap<String, Object>, Person> TRANSFORM_FUNCTION = new Function<ImmutableMap<String, Object>, Person>()
    {
        @Override
        public Person apply(final ImmutableMap<String, Object> from)
        {
            return new Person(from.get("forename").toString(), from.get("surname").toString(), (Integer)from.get("age"));
        }
    };
    private final String forename;
    private final String surname;
    private final int age;

    public Person(final String forename, final String surname, final int age)
    {
        this.forename = forename;
        this.surname = surname;
        this.age = age;
    }

    @Override
    @SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
    public boolean equals(final Object otherObject)
    {
        return EqualsBuilder.reflectionEquals(this, otherObject);
    }

    @Override
    public int hashCode()
    {
        return HashCodeBuilder.reflectionHashCode(this);
    }

    @Override
    public String toString()
    {
        return ToStringBuilder.reflectionToString(this);
    }
    
    /**
     * @return the forename
     */
    public String getForename()
    {
        return forename;
    }

    /**
     * @return the surname
     */
    public String getSurname()
    {
        return surname;
    }

    /**
     * @return the age
     */
    public int getAge()
    {
        return age;
    }
}
